package fr.km.client.model.tools;

import java.util.ArrayList;
import java.util.Iterator;

import fr.km.client.model.Article;

public class ArticleTools {
	public static String getTagsAsString(Article article) {
		ArrayList<String> tags = article.getTags();
		Iterator<String> iterator = tags.iterator();
		StringBuilder s = new StringBuilder();
		while(iterator.hasNext()) {
			s.append(iterator.next());
			if(iterator.hasNext()) {
				s.append(", ");
			}
		}
		
		return s.toString();
	}
	
	public static ArrayList<String> getTagsFromString(String tags) {
		ArrayList<String> tagList = new ArrayList<String>();
		String[] split = tags.split(",");
		for(String s : split) {
			s = s.trim();
			if(!s.equals("")) {
				tagList.add(s);
			}
		}
		
		return tagList;
	}
}
